<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <%@include file="/WEB-INF/views/include/weixinhead.jsp" %>
    <script src="${ctxStatic}/modules/wechat/js/rip.js"></script>
    <script src="${ctxStatic}/modules/wechat/js/interface.js"></script>
    <%--<script src="${ctxStatic}/modules/wechat/js/studyAbroad.js"></script>--%>
</head>
<body>

<!--模拟考试-->
<div data-role="page" id="studyAborad" class="page">
    <div data-role="header" class="header header-1" id="examHeader">
        <span class="return-btn"><a href="/f/campusinfo/simulationTest" data-ajax="false" data-transition="slideup"><img src="${ctxStatic}/modules/wechat/css/images/yuanjiaojuxing25.png" alt=""></a></span>
    </div>
    <div role="main" class="content">
        <div class="account border-5">
            <div class="re-left">考试名称</div>
            <div class="re-right"><input id="examName" type="text" readonly value=""></div>
        </div>
        <div class="account border-6">
            <div class="re-left">考试简介</div>
            <div class="re-right"><textarea id="examContent" readonly></textarea></div>
        </div>
        <div class="account border-5">
            <div class="re-left">考试费用</div>
            <div class="re-right">
                <input id="examPrice" type="text" readonly  value="" style=" padding: 0px;">
                <div style="height: 14px;font-size:14px;color: #fd3e8b;position: absolute;right:12px;bottom: 0px;">元</div>
            </div>
        </div>
        <div class="account border-5" style="border-bottom: none;height:78px;">
            <div class="re-left">线上缴费</div>
            <div class="re-right" style="height:40px !important;margin-bottom: 12px">
                <a href="" data-ajax="false">
                    <div id="Graduate-zhifubao-exam-btn">
                        <img src="${ctxStatic}/modules/wechat/css/images/icon-zhifubao.png" alt="支付宝支付">
                    </div>
                </a>
                <a href="" data-ajax="false">
                    <div id="Graduate-weixin-exam-btn">
                        <img src="${ctxStatic}/modules/wechat/css/images/icon-weixin.png" alt="微信支付">
                    </div>
                </a>
            </div>
        </div>
        <div class="account border-5" style="border-bottom: none">
            <div class="re-left">线下缴费</div>
            <div class="re-right"><label id="address" style="font-size: 14px;padding-left: 14px"></label></div>
        </div>
        <button id="Graduate-school-exam-btn" onclick="">确认</button>
    </div>
    <div class="footer">
        <p class="Consulting-phone"></p>
        <p class="Consulting-WeChat"></p>
    </div>
</div>
<script>
    $(document).ready(function(){
        var type,name,content,price,payMethod,address,id;
        /*先判断用户是否在线*/
        $.ajax({
            url:interfaceGetState+generateMixed(9),
            type:'post',
            success:function (data) {
                if(data.status==0){
                    //已登录
                    /*是否实名*/
                    realName();
                    if(window.sessionStorage){
                        id=sessionStorage.getItem("examId");
                        if(id==null){
                            var url=window.location.href;
                            id=url.split("?")[1].split("&")[0].split("=")[1];
                        }
                    }else {
                        var url=window.location.href;
                         id=url.split("?")[1].split("&")[0].split("=")[1];
                    }
                    // console.log(id);
                    $.ajax({
                        url:interfaceExamDetail+generateMixed(9),
                        type:'post',
                        data:{id:id},
                        success:function(data){
                            // console.log(data);
                            type=data.page.examType;
                            name=data.page.examName;
                            content=data.page.examForshort;
                            price=data.page.payment;
                            address=data.page.unLinement;
                            // console.log(id);
                            $("#examHeader").prepend(type);    //头部，考试科目
                            $("#examName").val(name);      //考试名称
                            $("#examContent").val(content);   //考试简介
                            $("#examPrice").val(price);      //考试费用
                            $("#address").html(address);  //线下缴费地点
                        }
                    })
                }else {
                    //未登录
                    alert("请先登录");
                    if(window.sessionStorage){
                        var url=window.location.href;
                        sessionStorage.setItem("prePage",url);
                    }
                    window.location.href="/f/campusinfo/login"+generateMixed(9);
                    return false;
                }
            }
        });
        $("#Graduate-school-exam-btn").off("tap").on("tap",function(){
            /*先判断用户是否在线*/
            // console.log(id);
            $.ajax({
                url:interfaceGetState+generateMixed(9),
                type:'post',
                success:function (data) {
                    if(data.status==0){
                        //已登录
                        /*是否实名*/
                        realName();
                        if(real){   //已实名
                            $.ajax({
                                url:interfaceApplyForExam+generateMixed(9),
                                type:'post',
                                data:{payment:price,paymentMethod:3,paymentPlace:address,examId:id},
                                success:function(data){
                                    if(data.success){
                                        alert(data.message);
                                        window.history.back(-1);
                                    }else{
                                        alert(data.message);
                                    }
                                }
                            });
                        }else{      //未实名
                            alert("未实名，请完善个人信息")
                        }
                    }else {
                        //未登录
                        alert("请先登录");
                        if(window.sessionStorage){
                            var url=window.location.href;
                            sessionStorage.setItem("prePage",url+"?id="+id);
                        }
                        window.location.href="/f/campusinfo/login"+generateMixed(9);
                    }
                }
            });
        })
        $("#Graduate-zhifubao-exam-btn").off("tap").on("tap",function(){
            /*先判断用户是否在线*/
            // console.log(id);
            $.ajax({
                url:interfaceGetState+generateMixed(9),
                type:'post',
                success:function (data) {
                    if(data.status==0){
                        //已登录
                        /*是否实名*/
                        realName();
                        if(real){   //已实名
                            $.ajax({
                                url:interfacealipayAddexam+generateMixed(9),
                                type:'post',
                                data:{payment:price,paymentMethod:2,paymentPlace:address,examId:id,examName:name},
                                success:function(data){
                                    if(data.success){
                                        var src = data.campusinfoExam
                                        window.location.href="/alipay/pay"+"?orderNo="+src.orderCode;
                                    }else{
                                        alert(data.message);
                                    }
                                }
                            });
                        }else{      //未实名
                            alert("未实名，请完善个人信息")
                        }
                    }else {
                        //未登录
                        alert("请先登录");
                        if(window.sessionStorage){
                            var url=window.location.href;
                            sessionStorage.setItem("prePage",url+"?id="+id);
                        }
                        window.location.href="/f/campusinfo/login"+generateMixed(9);
                    }
                }
            });
        })
        //微信支付
        $("#Graduate-weixin-exam-btn").off("tap").on("tap",function(){
            /*先判断用户是否在线*/
            // console.log(id);
            $.ajax({
                url:interfaceGetState+generateMixed(9),
                type:'post',
                success:function (data) {
                    if(data.status==0){
                        //已登录
                        /*是否实名*/
                        realName();
                        if(real){   //已实名
                            $.ajax({
                                url:interfacealipayAddexam+generateMixed(9),
                                type:'post',
                                data:{payment:price,paymentMethod:1,paymentPlace:address,examId:id,examName:name},
                                success:function(data){
                                    if(data.success){
                                        var src = data.campusinfoExam
                                        window.location.href="/alipayWeixin/pay/order"+"?orderNo="+src.orderCode;
                                    }else{
                                        alert(data.message);
                                    }
                                }
                            });
                        }else{      //未实名
                            alert("未实名，请完善个人信息")
                        }
                    }else {
                        //未登录
                        alert("请先登录");
                        if(window.sessionStorage){
                            var url=window.location.href;
                            sessionStorage.setItem("prePage",url+"?id="+id);
                        }
                        window.location.href="/f/campusinfo/login"+generateMixed(9);
                    }
                }
            });
        })
    })
</script>
</body>
</html>
